<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
         <ui:composition template="/templates/default.xhtml">
             <ui:define name="content">
                <h:form>
                    <h:commandButton value="#{locale.buttonNewStudyprogram}" action="#{newStudyProgram.addNewStudyProgram}" />
                    <p/>
                    <h:dataTable value="#{studyprogramList.studprogs}" var="sp" >
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderStudprogCode}
                            </f:facet>
                            <h:inputText value="#{sp.studyProgramCode}" rendered="#{sp.editable}" size="8"/>
                            <h:outputText value="#{sp.studyProgramCode}" rendered="#{not sp.editable}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderStudprogName}
                            </f:facet>
                            <h:inputText value="#{sp.name}" rendered="#{sp.editable}" size="40"/>
                            <h:outputText value="#{sp.name}" rendered="#{not sp.editable}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderStudprogApproved}
                            </f:facet>
                            <h:inputText value="#{sp.approved}" rendered="#{sp.editable}" size="10" >
                                <f:convertDateTime pattern="yyyy-MM-dd"/>
                            </h:inputText>
                            <h:outputText value="#{sp.approved}" rendered="#{not sp.editable}" >
                                <f:convertDateTime pattern="yyyy-MM-dd"/>
                            </h:outputText>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderStudprogApprovedBy}
                            </f:facet>
                            <h:inputText value="#{sp.approvedBy}" rendered="#{sp.editable}" size="10" />
                            <h:outputText value="#{sp.approvedBy}" rendered="#{not sp.editable}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderStudprogRevised}
                            </f:facet>
                            <h:inputText value="#{sp.lastRevised}" rendered="#{sp.editable}" size="10" >
                                <f:convertDateTime pattern="yyyy-MM-dd"/>
                            </h:inputText>
                            <h:outputText value="#{sp.lastRevised}" rendered="#{not sp.editable}" >
                                <f:convertDateTime pattern="yyyy-MM-dd"/>
                            </h:outputText>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderStudprogIsNKR}
                            </f:facet>
                            <h:selectBooleanCheckbox value="#{sp.isNKR}" rendered="#{sp.editable}" />
                            <h:outputText value="#{sp.isNKR}" rendered="#{not sp.editable}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderDepartment}
                            </f:facet>
                            <h:selectOneMenu value="#{sp.department.departmentID}" rendered="#{sp.editable}" >
                                <f:selectItem itemLabel="#{locale.selectDepartment}" itemValue=""/>
                                <f:selectItems value="#{newStudyProgram.departments}" var="dep" itemLabel="#{dep.name}" itemValue="#{dep.departmentID}"/>
                            </h:selectOneMenu>
                            <h:outputText value="#{sp.department.departmentID}" rendered="#{not sp.editable}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderEdit}
                            </f:facet>
                            <h:commandButton value="#{locale.buttonEdit}" action="#{sp.setEditable(true)}" rendered="#{not sp.editable}" />
                            <h:commandButton value="#{locale.buttonSave}" action="#{studyprogramList.executeChanges}" rendered="#{sp.editable}" />
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                #{locale.dtHeaderDelete}
                            </f:facet>
                            <h:commandButton value="#{locale.buttonDelete}" action="#{studyprogramList.setDeleteFlagAndNavigate(sp)}" />
                        </h:column>
                    </h:dataTable>
                 </h:form>
             </ui:define>
         </ui:composition>
    </h:body>
</html>

